
/*
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#include "config.h"

#include "splay-tree.h"

#ifndef MAIN_H
#define MAIN_H 1

/* font */
#define DRAWING_DEFAULT_FONTNAME "serif"
#define DRAWING_DEFAULT_FONTSIZE 10

extern char *inputfilename;
extern int settings_init_folded;
/* drawing mode 0 is centered, 1 is wide drawing */
extern int viewmode;

struct mpool;
struct unode;
struct uedge;
struct usubg;

struct dln;
struct dle;
struct dlsg;

struct usubg
{
  char *name;			/* unique name of subgraph */
  char *label;			/* display label text */
  struct unode *summaryn;	/* folded summary node */
  struct usubg *rootedon;
  struct usubg *next;
  struct dlsg *sg;		/* list of subgraphs in this subgraph */
  struct dlsg *sgend;
  struct dln *nl;		/* list of nodes defined in this subgraph */
  struct dln *nlend;
  struct dle *el;		/* list of edges defined in this subgraph */
  struct dle *elend;
  struct
  {
    unsigned int done:1;	/* if set subgraph folding is done */
    unsigned int folded:1;	/* if set subgraph is folded in summary node un */
    unsigned int visible:1;	/* if set whole subgraph is visible */
    unsigned int summary:1;	/* if set summary node is visible */
  } bitflags;
};

struct unode
{
  char *name;			/* unique name of node to reference */
  char *label;			/* text of node in the drawing */
  int number;			/* unique number of node */
  int color;			/* color of background */
  unsigned char shape;		/* node shape, box ellips etc. */
  struct usubg *rootedon;	/* node is part of subgraph or NULL if in rootgraph */
  int nx;			/* node shape outer box x size */
  int ny;			/* node shape outer box y size */
  int tx;			/* node shape inner box text area x size */
  int ty;			/* node shape inner box text area y size */
  int textcolor;		/* color of label text */
  int fontsize;			/* size of font for label text range 1..100 and 0 is gtk default */
  char *fontname;		/* name of font to use default "serif" used if NULL */
  int objectnr;			/* uniq object number for dia */
  struct
  {
    unsigned int done:1;
    unsigned int hasin:1;	/* node has incoming edges connections */
    unsigned int hasout:1;	/* node has outgoing edges connections */
    unsigned int edgelabel:1;	/* node is edgelabel to draw different */
    unsigned int singlenode:1;	/* set if node has no edge connections */
    unsigned int inwnl:1;	/* set if node is in working node list */
    unsigned int sumnode:1;	/* set if node is a subgraph summary node */
    unsigned int defbyedge:1;	/* set if node is defined by edge statement */
    unsigned int defbynode:1;	/* set if node is defined by node statement */
    unsigned int parseerror:1;	/* set if node is a parse error message */
    unsigned int textitalic:1;	/* label text is in slant italic */
    unsigned int textoblique:1;	/* label text is in slant oblique */
    unsigned int textbold:1;	/* label text is in weight bold */
    unsigned int selfedge:1;	/* if set node is part of selfedge */
  } bitflags;
};

struct uedge
{
  struct unode *fn;		/* from node */
  struct unode *tn;		/* to node */
  struct usubg *rootedon;	/* edge is defined in subgraph */
  int color;			/* color of edge line */
  int style;			/* solid, dotted, dashed style of edge line */
  char *label;			/* edgelabel or null */
  int textcolor;		/* color of label text */
  int fontsize;			/* size of font for label text range 1..100 and 0 is gtk default */
  char *fontname;		/* name of font to use default "serif" used if NULL */
  struct
  {
    unsigned int done:1;
    unsigned int inwel:1;	/* set if edge is in working edge list */
    unsigned int inedge:1;	/* edge is inside subgraph not crossing subgraphs */
    unsigned int selfedge:1;	/* edge is a self edge */
    unsigned int textbold:1;	/* label text is in weight bold */
    unsigned int textitalic:1;	/* label text is in slant italic */
    unsigned int textoblique:1;	/* label text is in slant oblique */
  } bitflags;
};

struct dln
{
  struct dln *next;
  struct dln *prev;
  struct unode *un;
};

struct dle
{
  struct dle *next;
  struct dle *prev;
  struct uedge *ue;
};

struct dlsg
{
  struct dlsg *next;
  struct usubg *sg;
};

struct dn
{
  int pos;
  int level;
  struct unode *un;
  int x0;
  int y0;
  int x1;
  int y1;
  int x2;
  int y2;
  int y3;
  struct dn *next;
};

struct de
{
  struct dn *from;
  struct dn *to;
  int color;
  int style;
  int reversed;
  struct de *next;
};

/* edge line styles */
#define ESTYLE_NORMAL 0		/* solid edge line */
#define ESTYLE_SOLID 0		/* solid edge line */
#define ESTYLE_DOTTED 1		/* dotted edge line */
#define ESTYLE_DASHED 2		/* dashed edge line */
#define ESTYLE_INVIS 4		/* invisible edge line */

/* node shapes */
#define NSHAPE_ELLIPS 0		/* 0 is default shape */
#define NSHAPE_CIRCLE 2
#define NSHAPE_BOX 1
#define NSHAPE_RBOX 3

#endif

/* End */
